Conventionally, a magnetic sensor is widely used for applications, such as detection of a rotational position of vehicle steering or the like or detection of the linear displacement of an object. The magnetic sensor is a sensor that can detect the rotational position or linear displacement of an object, by detecting the orientation and magnitude of a magnetic field that is generated from a magnet placed in an object to be detected. Recently, a magnetoresistive effect element (MR element), which is a multilayer body having a magnetization free layer and a magnetization pinned layer, where the resistance of the MR element varies in accordance with a change of the magnetization direction of the free layer according to an external magnetic field, has been widely used as a magnetic sensor. When the external magnetic field acts on the MR element, the magnetization direction of the magnetization free layer is changed, and the relative angle with the magnetization direction in the magnetization pinned layer is changed. The change of the magnetization direction appears as a change in the magnetic resistance of the MR element, enabling the detection of the intensity of the external magnetic field.